package view.component.main
{
	import controller.startup.MH4WikiContext;
	
	
	import org.robotlegs.mvcs.StarlingContext;
	
	import starling.display.Sprite;
	import starling.events.Event;
	
	import view.theme.CustomTheme;
	
	
	/**
	 * Wiki主应用
	 * @author £iang
	 * 
	 */	
	public class MH4Wiki extends Sprite
	{
		//-----------------------------
		// variables
		//-----------------------------
		
		/** 主界面 */
		public var mainView:MainView;
		
		//-----------------------------
		// properties
		//-----------------------------
		
		/** RobotLegsContext */
		private var _starlingContext:StarlingContext;
		
		private var _theme:CustomTheme;
		
		//-----------------------------
		// setter&getter
		//-----------------------------
		
		//-----------------------------
		// methods
		//-----------------------------
		
		//-----------------------------
		// events
		//-----------------------------
		
		/**
		 * 处理主应用添加到舞台后派发的事件 
		 * @param event 主应用添加到舞台后派发的事件 
		 * 
		 */			
		private function addedToStageHandler( event:Event ):void
		{
			this.removeEventListener( Event.ADDED_TO_STAGE, addedToStageHandler );
			this._theme = new CustomTheme( this.stage );
			mainView = new MainView();
			this.addChild( mainView );
		}
		
		//-----------------------------
		// dispose
		//-----------------------------
		
		/**
		 * 析构函数 
		 * 
		 */		
		override public function dispose():void
		{
			//删侦听
			this.removeEventListeners();
			super.dispose();
		}
		
		//-----------------------------
		// construction
		//-----------------------------
		
		/**
		 * 构造函数
		 *
		 */
		public function MH4Wiki()
		{
			super();
			_starlingContext = new MH4WikiContext( this );
			this.addEventListener( Event.ADDED_TO_STAGE, addedToStageHandler );
		}
	}
}